<template>
  <div class="blog-list">
    <mu-container>
      <h2>博客列表</h2>
      <ul>
        <li v-for="item in blogList" :key="item.title">
          <h3>{{item.title}}</h3>
          <div class="content">
            <article>{{item.content}}</article>
            <span>{{item.date}}</span>
            <router-link :to="'/BlogDetail/'+item.id">
              <button>查看详情</button>
            </router-link>

          </div>

        </li>
      </ul>
    </mu-container>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "BlogList",
  data() {
    return {
      blogList: []
    };
  },
  created() {
    axios
      .get("https://wd4276888673xfbavi.wilddogio.com/blog.json")
      .then(response => {
        console.log(response);
        let data = response.data;

        let blogList = [];
        for (let i in data) {
          data[i].id = i;
          blogList.push(data[i]);
        }
        this.blogList = blogList;
      })
      .catch(err => {
        console.log(err);
      });
  },
  methods:{
    
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
ul {
  list-style: none;
}
li {
  background: #ddd;
  padding: 30px;
  border: 3px solid #fff;
}
h3 {
  padding-bottom: 20px;
}
</style>
